<?php
/*本方法只适用于纯php代码*/

$loadFileName = "../original.php";
$saveFileName = "encrypting.php";

//读取文件
$file = file_get_contents( $loadFileName );
//去除php头
$deal = str_replace( "<?php\n", "", $file );
//把文件内容转为base64
$encrypting = base64_encode( $deal );
//增加eval
$eval = "<?php\neval(base64_decode(\"" . $encrypting . "\"));";
//把加密后到结果写入到文件
file_put_contents( $saveFileName , $eval );
//显示文件内容
echo $eval;